﻿@page "/graph"

@inject IHttpService _httpService
<MakeSureInWASMTip>
    <div class="rounded shadow-sm bg-opacity p-4" style=" overflow: scroll;">
        @if (isReady)
        {
            <MECharts Option="Model" Width="1500" Height="1500">
            </MECharts>
        }
        else
        {
            <CnGalWebSite.Components.Progressings.ProgressingCard Page Fill />
        }

    </div>
    @code {
        [CascadingParameter]
        public ErrorHandler ErrorHandler { get; set; }

        bool isReady;
        EChartsGraphOptionModel Model;
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            if (firstRender)
            {
                try
                {
                    Model = await _httpService.GetAsync<EChartsGraphOptionModel>("api/tables/GetEntryGraph");
                    isReady = true;
                    StateHasChanged();
                }
                catch (Exception ex)
                {
                    await ErrorHandler.ProcessError(ex, "无法获取词条关系图");
                }
            }
        }
    }

</MakeSureInWASMTip>
